/**
 * 工厂模式
 */

class Product {
    constructor(name) {
        this.name = name
    }
    init() {
        console.log('init...')
    }
    fn1() {
        console.log('fn1...')
    }
    fn2() {
        console.log('fn2...')
    }
}

class Creator {
    static create(name) {
        return new Product(name)
    }
}

function test() {
    const p = Creator.create('p1')
    p.init()
    p.fn1()
    p.fn2()
}

console.log('----------------工厂模式-------------------')
test()
